package org.zhadoop.stream.cql.semanticanalyzer.analyzecontext.expressiondesc;

import org.zhadoop.stream.api.streams.Column;
import org.zhadoop.stream.cql.CQLUtils;
import org.zhadoop.stream.cql.executor.expressioncreater.PropertyValueExpressionCreator;
import org.zhadoop.stream.cql.executor.operatorinfocreater.ExpressionCreatorAnnotation;
import org.zhadoop.streaming.exception.StreamingRuntimeException;

/**
 * propertyValue 表达式的描述信息
 * @author zwd
 *
 */
@ExpressionCreatorAnnotation(PropertyValueExpressionCreator.class)
public class PropertyValueExpressionDesc implements ExpressionDescribe{
	
	/**
	 * 属性
	 */
	private String property;
	
	/**
	 * 属性对应的数据类型
	 */
	private Class<?> type;

	/**
	 * 流名称
	 */
	private String schemaId;
	
	private int indexInSchemas;

	public PropertyValueExpressionDesc(String property, Class<?> type, String schemaId, int indexInSchemas) {
		super();
		this.property = property;
		this.type = type;
		this.schemaId = schemaId;
		this.indexInSchemas = indexInSchemas;
	}
	
	public PropertyValueExpressionDesc(Column attr,String schemaId, int indexInSchemas) {
		this.property = attr.getName();
		try {
			this.type = Class.forName(attr.getType(),true,CQLUtils.getClassLoader());
		} catch(ClassNotFoundException e) {
			throw new StreamingRuntimeException(e);
		}
		
		this.schemaId = schemaId;
		this.indexInSchemas = indexInSchemas;
	}

	public String getProperty() {
		return property;
	}

	public void setProperty(String property) {
		this.property = property;
	}

	public Class<?> getType() {
		return type;
	}

	public void setType(Class<?> type) {
		this.type = type;
	}

	public String getSchemaId() {
		return schemaId;
	}

	public void setSchemaId(String schemaId) {
		this.schemaId = schemaId;
	}

	public int getIndexInSchemas() {
		return indexInSchemas;
	}

	public void setIndexInSchemas(int indexInSchemas) {
		this.indexInSchemas = indexInSchemas;
	}
}
